package com.colodoo.framework.exception;

import com.colodoo.framework.common.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author zhisan
 */
@RestControllerAdvice
@Slf4j
public class GlobalException {

	@ExceptionHandler(value = AppException.class)
	@ResponseBody
	public Result restAppExceptionHandler(AppException e) {
		log.error(e.getMsg(), e);
		return Result.err(e.getMsg());
	}

	@ExceptionHandler(value = Exception.class)
	@ResponseBody
	public Result restExceptionHandler(Exception e) {
		log.error("系统异常", e);
		return Result.err("系统异常");
	}

}
